//
//  findDetailTableViewCell.m
//  A Learning Walk
//
//  Created by 张勇 on 16/6/15.
//  Copyright © 2016年 战斗民族. All rights reserved.
//

#import "findDetailTableViewCell.h"

@implementation findDetailTableViewCell



- (void)awakeFromNib {
    [super awakeFromNib];

    
    // Initialization code
}




-(void)Action:(NSNotification *)noti{
//
//    _model.isBool = [noti.object integerValue];
//    NSLog(@"bool === %d",_model.isBool);
//
//    if (_model.isBool == 0) {
//        NSLog(@" 000 ==== 走了吗");
//        self.PlayImageV.image = [UIImage imageNamed:@"toolbar_play_n"];
//    }else{
//        self.PlayImageV.image = [UIImage imageNamed:@"toolbar_pause_h"];
//        NSLog(@"sdafw");
//    }
    
    _model.isBool = YES;
}

-(void)setModel:(DetailListModel *)model{
    if (_model != model) {
        [_model release];
    }
    _model = [model retain];

    
    [self.bigImage sd_setImageWithURL:[NSURL URLWithString:_model.coverSmall] placeholderImage:[UIImage imageNamed:@"holderr"]];
    self.bigImage.layer.masksToBounds = YES;
    self.bigImage.layer.cornerRadius = self.bigImage.frame.size.width / 2;
    
    
    
    self.titleLabel.text = _model.title;
    self.titleLabel.numberOfLines = 0;
    self.titleLabel.backgroundColor = [UIColor clearColor];
    self.titleLabel.font = [UIFont systemFontOfSize:14];
    
    
    self.iconImageOne.image = [UIImage imageNamed:@"bofang"];
    self.iconImageTwo.image= [UIImage imageNamed:@"shijian"];
    self.iconImageThree.image = [UIImage imageNamed:@"xiaoxi"];
    self.iconImageThree.backgroundColor = [UIColor clearColor];
    self.iconImageTwo.backgroundColor = [UIColor clearColor];
    self.iconImageOne.backgroundColor = [UIColor clearColor];
    
    self.labelOne.font = [UIFont systemFontOfSize:10];
    self.labelOne.textColor = [UIColor grayColor];
 
    self.labelOne.backgroundColor = [UIColor clearColor];
    if (_model.playtimes.integerValue / 10000 >= 1) {
        self.labelOne.text = [NSString stringWithFormat:@"%ld.%ld万",_model.playtimes.integerValue / 10000,_model.playtimes.integerValue % 10000 / 1000];
    }else{
        self.labelOne.text = [NSString stringWithFormat:@"%ld",_model.playtimes.integerValue % 10000];
    
    }
    
    self.labelTwo.font = [UIFont systemFontOfSize:10];
    self.labelTwo.textColor = [UIColor grayColor];
    
    self.labelTwo.backgroundColor = [UIColor clearColor];
    if (_model.duration.integerValue % 60 >= 10) {
        self.labelTwo.text = [NSString stringWithFormat:@"%ld:%ld",_model.duration.integerValue / 60 , _model.duration.integerValue % 60];
    }else{
    
    self.labelTwo.text = [NSString stringWithFormat:@"%ld:%ld",_model.duration.integerValue / 60 , _model.duration.integerValue % 60 * 10];
    }
    
    self.labelThree.font = [UIFont systemFontOfSize:10];
    self.labelThree.textColor = [UIColor grayColor];
   
    self.labelThree.backgroundColor = [UIColor clearColor];
    self.labelThree.text = _model.comments;

#if 0
    self.PlayB = [UIButton buttonWithType:UIButtonTypeCustom];
    self.PlayB.frame = self.bigImage.bounds;
    self.PlayB.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:self.PlayB];
    [self.PlayB addTarget:self action:@selector(PlayBAction:) forControlEvents:UIControlEventTouchUpInside];
#endif
   // NSLog(@"===========  %d",_model.isBool);


//    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(Action:) name:@"bool" object:nil];
  
#if 0
    if (_model.isBool) {
        
        self.PlayB.backgroundColor = [UIColor blueColor];
        _model.isBool = YES;
    }
    
#endif
    
    
    
    
}

#if 0
//小button点击切换
-(void)PlayBAction:(UIButton *)button{
    
    
    if (self.model.isBool) {
        
        
        button.backgroundColor = [UIColor redColor];
        
        
    }else{
        
        
        button.backgroundColor = [UIColor blueColor];
        
    }
    
    
    self.model.isBool = !self.model.isBool;
    
    
}
#endif





- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)dealloc {
    [_bigImage release];
    [_titleLabel release];
    [_iconImageOne release];
    [_labelOne release];
    [_iconImageTwo release];
    [_labelTwo release];
    [_iconImageThree release];
    [_labelThree release];
    [_model release];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"bool" object:nil];
    [super dealloc];
}
@end
